<div class="contextual">   
	<% replace_watcher ||= 'watcher' %> 
	<%= watcher_tag(@invoice, User.current, {:id => replace_watcher, :replace => ['watcher','watcher2']}) if false %>  
	<%= link_to l(:button_edit), {:controller => 'invoices', :action => 'edit', :id => @invoice}, :class => 'icon icon-edit' if !@invoice.nil? && @invoice.editable_by?(User.current) %> 
	<%= link_to_if_authorized l(:button_download), {:controller => 'invoices', :action => 'show', :id => @invoice, :format => 'pdf'}, :class => 'icon icon-pdf' unless @invoice.nil? %>
	<%= link_to_if_authorized l(:button_send_mail), {:controller => 'invoice_mails', :action => 'send', :id => @invoice}, :class => 'icon icon-email' unless @invoice.nil? %>
	<%= link_to l(:button_delete), {:controller => 'invoices', :action => 'destroy', :id => @invoice}, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' if  !@invoice.nil? && @invoice.destroyable_by?(User.current) %>
</div>

<h2><%= "#{l(:label_invoice)} ##{@invoice.number}" %></h2>  

<div class="issue invoice details">

<div class="subject">      
<h3><%= "#{@invoice.contact.name + ' - ' if @invoice.contact}#{[@invoice.currency, invoice_price(@invoice.amount)].join(' ')}#{' - ' + @invoice.subject unless @invoice.subject.blank?}" %></h3>  
</div>
        <p class="author">
        <%= authoring @invoice.created_at, @invoice.author %>.
        <% if @invoice.created_at != @invoice.updated_at %>
        <%= l(:label_updated_time, time_tag(@invoice.updated_at)).html_safe %>.
        <% end %>
        </p>

<table class="attributes invoice status-<%= @invoice.status_id %>">
<tr>
    <th class="status"><%=l(:field_invoice_status)%>:</th><td class="status"><%= invoice_status_tag(@invoice) %></td>
    <th class="start-date"><%=l(:field_invoice_date)%>:</th><td class="start-date"><%= format_date(@invoice.invoice_date) %></td>
</tr>
<tr>
    <th class="contact"><%=l(:field_invoice_language)%>:</th><td class="language"><%= invoice_avaliable_locales_hash[@invoice.language.blank? ? 'default' : @invoice.language] %></td>
    <th class="due-date"><%=l(:field_invoice_due_date)%>:</th><td class="due-date"><%= format_date(@invoice.due_date) %></td>
</tr>
<tr>
    <th class="contact"><%=l(:field_invoice_contact)%>:</th><td class="contact"><%= !@invoice.contact.blank? ? link_to_contact(@invoice.contact, :avatar => true).html_safe : "" %></td>
    <th class="progress"><%=l(:field_invoice_discount)%>:</th><td class="progress"><%= progress_bar @invoice.discount_rate, :width => '80px', :legend => "#{@invoice.discount_rate.to_f.round(2)}% / #{invoice_price(@invoice.discount_amount)}" %></td>
</tr>
<tr>
    <th class="assigned-to"><%=l(:field_invoice_assigned_to)%>:</th><td class="assigned-to"><%= avatar(@invoice.assigned_to, :size => "14") %><%= @invoice.assigned_to ? link_to_user(@invoice.assigned_to) : "-" %></td>
</tr>
<%= call_hook(:view_invoices_show_details_bottom, :invoice => @invoice) %>
</table>


<% if @invoice.description? %>
  <hr />
	<p><strong><%=l(:field_description)%></strong></p>
	<div class="wiki">
	<%= textilizable @invoice, :description, :attachments => @invoice.attachments %>
	</div>
<% end %>


<hr />
<p><strong><%= l(:label_invoice_lines) %></strong></p>
<div class="invoice-lines">
<%= render :partial => 'invoice_lines' %>
</div>


</div>

<% content_for :sidebar do %>
  <div class="contact-card small-card">
    <h3><%= l(:label_contact) %></h3>
    <%= render :partial => 'contacts/contact_card', :object => @invoice.contact %>
  </div>
  <%= render :partial => 'stat_invoiced' %>
  <%= render :partial => 'stat_status' %>
<% end if @invoice.contact %>

<% html_title "#{l(:label_invoice)} ##{@invoice.number}" %> 

<% content_for :header_tags do %>
	<%= javascript_include_tag :contacts, :plugin => 'redmine_contacts' %>   
	<%= stylesheet_link_tag :contacts, :plugin => 'redmine_contacts' %> 
	<%= stylesheet_link_tag :contacts_invoices, :plugin => 'redmine_contacts_invoices' %> 
	<meta name = "format-detection" content = "telephone=no">
<% end %>
